# !/bin/bash


if [ -n "$2" ]; then
  data_date=$2
else
  data_date=$(date -d "-1 days" +%F)
fi

ods_md_areas="
load data inpath 'hdfs://node101:8020/warehouse/app_basic/t_md_areas/${data_date}/part-m-00000'
                  overwrite into table jtp_app_ods.ods_md_areas partition (dt='${data_date}');"

ods_event_app_log="
load data inpath '/warehouse/app_logs/${data_date}'
    overwrite into table jtp_app_ods.ods_event_app_log partition (dt='${data_date}');"


case $1 in
"all")
  /opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e "${ods_md_areas}${ods_event_app_log}"
  ;;
"ods_md_areas")
  /opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e "${ods_md_areas}"
 ;;
"ods_event_app_log")
  /opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e "${ods_event_app_log}"
;;
esac
